from sqlalchemy.orm import mapper,relation
from persist.tables import table_company,table_project,table_employee,table_order,table_delivery,table_dish

class Employee(object):
    def __repr__(self):
        return "%s{%s,%s}" %(self.__class__.__name__,self.id,self.name)
mapper(Employee,table_employee)

class Project(object):
    def __repr__(self):
        return "%s{%s,%s}" %(self.__class__.__name__,self.id,self.name)
mapper(Project,table_project,properties={'employees':relation(Employee,backref='project')})

class Company(object):
    def __repr__(self):
        return "%s{%s,%s}" %(self.__class__.__name__,self.id,self.name)
mapper(Company,table_company,properties={'projects':relation(Project,backref='company')})

class Dish(object):
    def __repr__(self):
        return "%s{%s,%s}" %(self.__class__.__name__,self.id,self.name)
mapper(Dish,table_dish)

class Delivery(object):
    def __repr__(self):
        return "%s{%s,%s}" %(self.__class__.__name__,self.id,self.name)
mapper(Delivery,table_delivery,properties={'dishes':relation(Dish,backref='delivery')})

class OrderItem(object):
    def __repr__(self):
        return "%s{%s,%s}" %(self.__class__.__name__,self.id,self.name)
mapper(OrderItem,table_order)